Import('env')
import os

local_env = env.Clone()

local_env.AppendUnique(CPPPATH=[
    os.path.join(Dir('.').abspath, './include'),
    os.path.join(Dir('.').abspath, './../logger/include'),
])

if env.get('ROUTING') == 'GW':
    local_env.AppendUnique(CPPPATH=[
        os.path.join(Dir('.').abspath, './../include'),
        os.path.join(Dir('.').abspath, './../stack/include'),
        os.path.join(Dir('.').abspath, './../stack/include/internal'),
        os.path.join(Dir('.').abspath, './../../oc_logger/include'),
        os.path.join(Dir('.').abspath, './../../c_common/ocrandom/include'),
        os.path.join(Dir('.').abspath, './../connectivity/api'),
        os.path.join(Dir('.').abspath, './../connectivity/common/inc'),
        os.path.join(Dir('.').abspath, './../security/include'),
        os.path.join(Dir('.').abspath, './../connectivity/external/inc')
    ])
elif env.get('ROUTING') == 'EP':
    local_env.AppendUnique(CPPPATH=[
        os.path.join(Dir('.').abspath, './../include'),
        os.path.join(Dir('.').abspath, './../stack/include'),
        os.path.join(Dir('.').abspath, './../stack/include/internal'),
        os.path.join(Dir('.').abspath, './../../oc_logger/include'),
        os.path.join(Dir('.').abspath, './../connectivity/api'),
        os.path.join(Dir('.').abspath, './../connectivity/common/inc'),
        os.path.join(Dir('.').abspath, './../connectivity/external/inc')
    ])

######################################################################
# Build flags
######################################################################

if env.get('LOGGING') == '1':
    local_env.AppendUnique(CPPDEFINES=['TB_LOG'])

######################################################################
# Source files and Targets
######################################################################

if env.get('ROUTING') == 'GW':
    routing_src = [
        './src/routingutility.c',
        './src/routingmanager.c',
        './src/routingtablemanager.c',
        './src/routingmanagerinterface.c',
        './src/routingmessageparser.c',
    ]
elif env.get('ROUTING') == 'EP':
    routing_src = [
        './src/routingutility.c',
    ]

routinglib = local_env.StaticLibrary('routingmanager', routing_src)
local_env.InstallTarget(routinglib, 'routingmanager')

